In [1]:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import sys
sys.path.insert(0, 'C:\Users\Dominik\Documents\GitRep\kt-2015-DSPHandsOn\MedianFilter\Python') #Add a new path with needed .py files
import functions
import gitInformation
In [2]:
gitInformation.printInformation()
In [3]:
% matplotlib inline
Here I'm plotting sine waves with different wave numbers. The different sine waves get median filtered and the filtered wave is displayed in the same plot. At least I am calculating the difference between the sine wave and the median filtered wave.
Here you can see the result. The blue wave is the sine, green the filtered wave and red is the difference between sine wave and filtered wave.
In [4]:
pp = PdfPages('median sin with different window lengths.pdf')
for z in range (3, 16, 2):
# Creates different figures in one plot, z is the window length.
fig = plt.figure(z, figsize=(30,20))
for x in range(1, 5):
for y in range(1, 6):
# Creates different subplots in one figure, with x and y
# the wave number is calculated.
plt.subplot(5, 5, x + (y-1)*4)
wavenum = (x-1) + (y-1)*4
functions.medianSinPlot( wavenum, z )
plt.suptitle('Median filtered sine waves with window length ' +
str(z), fontsize = 60)
plt.xlabel(("Wave number = "+str((x-1) + (y-1)*4)), fontsize=18)
pp.savefig(fig)
pp.close()